Imports System.IO
Public Class MapEditorNewTemplate
    Inherits System.Windows.Forms.Form
    Implements IMessageFilter
    Private WM_KEYDOWN As Integer = &H100
    Private WM_KEYUP As Integer = &H101
    Public CreateType As String = ""
    Public Function PreFilterMessage(ByRef m As Message) As Boolean Implements IMessageFilter.PreFilterMessage
        Dim keyCode As Keys = CType(CInt(m.WParam), Keys) And Keys.KeyCode
        If m.Msg = WM_KEYDOWN And keyCode = Keys.Escape Then
            Me.Close()
            Application.RemoveMessageFilter(Me) : Return True
        End If
        Return False
    End Function 'PreFilterMessage
    Private Sub CancelCreate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub

    Private Sub Accept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Accept.Click
        MapEditor.CreatedSomething(CreateType, TextBox1.Text)
        Me.Close()
    End Sub
End Class